#ifndef DPGAMELOGIC_H
#define DPGAMELOGIC_H
#include <vector>
#include <map>

class DPGameLogic
{
public:
    DPGameLogic(int rows, int cols, int maxUsedTexs);
    virtual ~DPGameLogic() ;

public:
    struct Node
    {
        int  texIndex;
        bool bStayed;
    };

    void generalMap();
    void changeIndex(int x1, int y1, int x2, int y2);
    bool check(int y, int x);
    bool checkStep(int x1, int y1, int x2, int y2);
    bool checkMap();
	int  getTexIndex(int x, int y) const;
	int  getTexIndex(int index) const;
    int  getRows() const { return mRows; }
    int  getCols() const { return mCols; }
    int  getMaxUsedTexs() const { return mMaxUsedTexs; }

    const std::vector<int>& getDelNodes(){ return mDeleteNodes; }
    const std::map<int,std::vector<int> >& getUpdateNodes() { return mUpdateNodes; }

    int  getScore() const { return mScore; }
	float getScoreEx() const { return mScoreEx; };
	void setScoreEx(const std::map<int,float>& indexToScore) { mIndexToScore = indexToScore; };

private:
    int mRows, mCols;
    int mMaxUsedTexs;
    int mScore;
	float mScoreEx;
    Node* mNodes;
    bool* mFlags;

	std::map<int,float> mIndexToScore;
    std::vector<int>		    mDeleteNodes;
    std::map<int,std::vector<int> > mUpdateNodes;
};

#endif // DPGAMELOGIC_H
